package com.sztz.controller;

import cn.hutool.json.JSONUtil;
import com.sztz.vo.wx.WxSignVo;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;

/**
 * 微信开发平台交互接口
 * @author yzy
 * @date 2023/2/8 18:34
 */
@RestController
@RequestMapping("/wx")
@Slf4j
public class WxController {
    /**
     * 提供给微信开发平台配置时验证
     * @param wxSignVo 微信开发平台发过来的数据
     * @author yzy
     * @date 2023/2/8 18:34
     */
    @SneakyThrows
    @PostMapping(value = "/signCheck")
    public String wxSignCheck(@RequestBody WxSignVo wxSignVo , HttpServletResponse httpServletResponse){
        log.info(JSONUtil.toJsonStr(wxSignVo));
        //httpServletResponse.getWriter().write(WxUtils.checkSign(wxSignVo)?wxSignVo.getEchostr(): StrUtil.EMPTY);
        return JSONUtil.toJsonStr(wxSignVo);
    }
}
